package kr.saeildamil.androidstudy.ch07;

import kr.saeildamil.androidstudy.R;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;

public class Vibrate extends Activity {
	Vibrator mVib;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vibrate);
		mVib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
	}

	protected void onDestroy() {
		super.onDestroy();
		mVib.cancel();
	}

	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.btnvibrate1:
			mVib.vibrate(500);
			break;
		case R.id.btnvibrate2:
			mVib.vibrate(new long[] { 100, 50, 200, 50 }, 0);
			break;
		case R.id.btnvibratestop:
			mVib.cancel();
			break;
		}
	}
}
